function insert(STRING, POS, INS, before_tmp) {
    before_tmp = substr(STRING, 1, POS)
    after_tmp = substr(STRING, POS + 1)
    return before_tmp INS after_tmp
    }

# main routine
{
    print "Function returns", insert($1, $2, "XX");
    print "The value of $1 after is:", $1
    print "The value of STRING is:", STRING
    print "The value of before_tmp:", before_tmp
    print "The value of after_tmp:", after_tmp
    }

# The value of $1 is the same after the function was called as it was before.
# The variable STRING is _local_ to the function and it does not have a value
# when called from the main routine. The same is true for before_tmp because
# its name was placed in the parameter list for the function definition. The
# variable after_tmp which was not specified in the parameter list does have
# a value, the letter "o".
#
# 定义在函数内部的变量为全局变量，而在参数列表中的变量为局部变量，函数对其的
# 修改一旦跳出作用域，则失效，所以参数列表中的变量并没有修改.好无敌的反常规则.

# As this example shows, $1 is passed "by value" into the function, a copy is
# made of the value when the function is called and the function manipulates
# the copy, not the original. Arrays, are passed "by reference", that is the
# function is does not work with a copy of the array but is passed the array
# itself, thus any changes that the function makes to the array are visible
# outside the function.
